package vip.xiaonuo.h5.royalty.modular.home.controller;

import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.h5.royalty.modular.home.param.HomeSummaryParam;
import vip.xiaonuo.h5.royalty.modular.home.param.BusinessCalendarParam;
import vip.xiaonuo.h5.royalty.modular.home.param.IncomeTrendParam;
import vip.xiaonuo.h5.royalty.modular.home.vo.HomeSummaryVo;
import vip.xiaonuo.h5.royalty.modular.home.vo.BusinessCalendarPage;
import vip.xiaonuo.h5.royalty.modular.home.vo.IncomeTrendPage;
import vip.xiaonuo.h5.royalty.modular.home.service.HomeService;

import javax.validation.Valid;

/**
 * 首页控制器
 */
@RestController
@RequestMapping("/h5/home")
public class HomeController {

    @Resource
    private HomeService homeService;

    /**
     * 获取首页今日昨日统计数据
     * @param homeSummaryParam 日期类型：today-今日，yesterday-昨日
     * @return 汇总数据
     */
    @PostMapping("/getSummary")
    public CommonResult<HomeSummaryVo> getSummary(@RequestBody @Valid HomeSummaryParam homeSummaryParam) {
        HomeSummaryVo result = homeService.getSummary(homeSummaryParam);
        return CommonResult.data(result);
    }

    /**
     * 获取经营日历数据
     * @param businessCalendarParam 查询参数（年份、月份、场站ID）
     * @return 日历数据
     */
    @PostMapping("/getBusinessCalendar")
    public CommonResult<BusinessCalendarPage> getBusinessCalendar(@RequestBody @Valid BusinessCalendarParam businessCalendarParam) {
        BusinessCalendarPage result = homeService.getBusinessCalendar(businessCalendarParam);
        return CommonResult.data(result);
    }

    /**
     * 获取收入趋势数据
     * @param incomeTrendParam 查询参数（年份、月份）
     * @return 收入趋势数据
     */
    @PostMapping("/getIncomeTrend")
    public CommonResult<IncomeTrendPage> getIncomeTrend(@RequestBody @Valid IncomeTrendParam incomeTrendParam) {
        IncomeTrendPage result = homeService.getIncomeTrend(incomeTrendParam);
        return CommonResult.data(result);
    }

}
